package com.moduls.data;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;

import com.moduls.data.common.AtoboUtil;
import com.moduls.interfaceFunction.core.SqlMapper;

public class DataService {

	@Autowired
	public SqlSession sqlSessions;
	
	//Atobo 城市数据添加
	public void atobo_city_add() throws IOException, SQLException {
		SqlMapper sqlMapper= new SqlMapper(sqlSessions);
		
		List<Map<String, String>> list = AtoboUtil.atoboCity();
		
		String sql = "insert into t_atobo (city_name,city_url) values ";
		
		for (Map<String, String> map : list) {
			String city_name = map.get("city_name");
			String city_url = map.get("city_url");
			sql+= "('"+city_name+",'"+city_url+"''),";
		}
		sql = sql.substring(0, sql.length()-1);
		
		System.out.println(sql);
		sqlMapper.insert(sql);
		
	}
	
}
